package com.bdv.md.common;

import com.bdv.md.controller.xmlattribute.Parameter;
import com.bdv.md.en.ConstantValues;
import com.bdv.md.en.RequestEn;

public class RequestThread implements Runnable {

	private Parameter param;
	private int type;
	private int refire;
	
	public void run() {
		System.out.println("Refire.. rettime:"+refire+" type:"+type);
		if(refire != 0){
			try {
				System.out.println("REFIRE "+param.getTrxId()+" in "+refire/1000+" sec");
				Thread.sleep(refire);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		if(type == ConstantValues.CC_AMR.getCode()) {
			RequestEn.CC_AMR.request(param);
		}else if(type == ConstantValues.CC_TOKEN_REQUEST.getCode()){
			RequestEn.CC_TOKEN_REQUEST.request(param);
		}else if(type == ConstantValues.CC_LIM_KREDIT.getCode()){
			RequestEn.CC_LIM_KREDIT.request(param);
		}else if(type == ConstantValues.CC_HISTORY_TOKEN.getCode()){
			RequestEn.CC_HISTORY_TOKEN.request(param);
		}else if(type == ConstantValues.CC_BILLING_HISTORY.getCode()){
			RequestEn.CC_BILLING_HISTORY.request(param);
		}else if(type == ConstantValues.CC_AMR_PP.getCode()){
			RequestEn.CC_AMR_PP.request(param);
		}else if(type == ConstantValues.CC_LOAD_PROFILE_PP.getCode()){
			RequestEn.CC_LOAD_PROFILE_PP.request(param);
		}else if(type == ConstantValues.CC_EVENT_LOG_PP.getCode()){
			RequestEn.CC_EVENT_LOG_PP.request(param);
		}else if(type == ConstantValues.CC_BILLING_PP.getCode()){
			RequestEn.CC_BILLING_PP.request(param);
		}else if(type == ConstantValues.CC_RECALL_LOAD_PROFILE_PP.getCode()){
			RequestEn.CC_RECALL_LOAD_PROFILE_PP.request(param);
		}else if(type == ConstantValues.CC_TIME_SYNC_PP.getCode()){
			RequestEn.CC_TIME_SYNC_PP.request(param);
		}else if(type == ConstantValues.CC_REMOTE_PP.getCode()){
			RequestEn.CC_REMOTE_PP.request(param);
		}else if(type == ConstantValues.CC_SCADA_SYSTEM_PP.getCode()){
			RequestEn.CC_SCADA_SYSTEM_PP.request(param);
		}
	}
	
	public RequestThread(Parameter param, int type, int refire){
		this.param=param;
		this.type=type;
		this.refire = refire;
	}

}
